package com.dqyt.khjc.controller;

import com.dqyt.khjc.bean.ResultMsg;
import com.dqyt.khjc.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 操作历史记录
 */
@RestController
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    /**
     * 分页查询 历史操作记录
     * @param request
     * @param page
     * @param size
     * @param opUserId  操作者
     * @param type 操作类型
     * @return
     */
    @RequestMapping(value = "/api/getHisListPage", method = {RequestMethod.GET,RequestMethod.POST})
    public ResultMsg getHisListPage(HttpServletRequest request,
                                       @RequestParam(defaultValue = "1") Integer page,
                                       @RequestParam(defaultValue = "10") Integer size,
                                       @RequestParam(name = "opUserId", required = false, defaultValue = "-1") long opUserId,
                                       @RequestParam(name = "type", required = false, defaultValue = "0") int type

    ){
        ResultMsg resultMsg = historyService.getHisListPage(request,page,size,opUserId,type);
        return resultMsg;
    }


    /**
     * 获取操作者下拉框列表
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/getmUserList", method = {RequestMethod.GET})
    public ResultMsg getmUserList(HttpServletRequest request){
       ResultMsg resultMsg = historyService.getmUserList(request);
        return resultMsg;
    }


    /**
     * 获取操作类型 下拉框列表
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/getOpList", method = {RequestMethod.GET})
    public ResultMsg getOpList(HttpServletRequest request){
        ResultMsg resultMsg = historyService.getOpList(request);
        return resultMsg;
    }

}
